package xyz.luxiaoxiang.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import xyz.luxiaoxiang.service.TopicService;

/**
 * 知乎的定时任务
 *
 * @author luxx
 * @date 2018/1/9 0009
 */
@Component
public class ZhiHuTask {

    /**
     * 每两天更新一次主、子主题
     */
    @Scheduled(cron = "0 0 3 ? * WED")
    public void topicTask() {
        topicService.refreshMainTopic();
        topicService.refreshChildTopic();
    }

    /**
     * 每天更新一次
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void hotQuestionTask() {
        topicService.getHotQuestionRemote();
    }

    @Autowired
    private TopicService topicService;
}
